home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / util / libs / muitoolkit_src.lha / muitoolkit_src / mt_init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-31  |  3.7 KB  |  120 lines

  1.  
  2. /*
  3. $Id: mt_init.c,v 1.2 1999/08/30 19:28:03 carlos Exp $.
  4. */
  5.  
  6. #include "mt_includes.h"
  7.  
  8.  
  9. ULONG __saveds __stdargs L_OpenLibs(struct MuiToolkitBase *MuiToolkitBase);
  10. void  __saveds __stdargs L_CloseLibs(void);
  11.  
  12. struct ExecBase      *SysBase       = NULL;
  13. struct IntuitionBase *IntuitionBase = NULL;
  14. struct GfxBase       *GfxBase       = NULL;
  15. struct Library       *UtilityBase   = NULL;
  16. struct DosLibrary    *DOSBase       = NULL;
  17. struct Library       *MUIMasterBase = NULL;
  18.  
  19. #define VERSION  1
  20. #define REVISION 0
  21.  
  22. #define EXLIBNAME "muitoolkit"
  23. #define EXLIBVER  " 1.00 (27.09.99)"
  24.  
  25. char __aligned ExLibName [] = EXLIBNAME ".library";
  26. char __aligned ExLibID   [] = EXLIBNAME EXLIBVER;
  27. char __aligned Copyright [] = "© Copyright 1999 Marcin Orlowski <carlos@amiga.com.pl> All rights reserved";
  28.  
  29. char __aligned VERSTRING [] = "\0$VER: " EXLIBNAME EXLIBVER;
  30.  
  31. /*************************************************************
  32. *************************************************************/
  33.  
  34. extern ULONG InitTab[];
  35. extern APTR EndResident; /* below */
  36.  
  37. struct Resident __aligned ROMTag =     /* do not change */
  38. {
  39.  RTC_MATCHWORD,
  40.  &ROMTag,
  41.  &EndResident,
  42.  RTF_AUTOINIT,
  43.  VERSION,
  44.  NT_LIBRARY,
  45.  0,
  46.  &ExLibName[0],
  47.  &ExLibID[0],
  48.  &InitTab[0]
  49. };
  50.  
  51. APTR EndResident;
  52.  
  53. struct MyDataInit                      /* do not change */
  54. {
  55.  UWORD ln_Type_Init;      UWORD ln_Type_Offset;      UWORD ln_Type_Content;
  56.  UBYTE ln_Name_Init;      UBYTE ln_Name_Offset;      ULONG ln_Name_Content;
  57.  UWORD lib_Flags_Init;    UWORD lib_Flags_Offset;    UWORD lib_Flags_Content;
  58.  UWORD lib_Version_Init;  UWORD lib_Version_Offset;  UWORD lib_Version_Content;
  59.  UWORD lib_Revision_Init; UWORD lib_Revision_Offset; UWORD lib_Revision_Content;
  60.  UBYTE lib_IdString_Init; UBYTE lib_IdString_Offset; ULONG lib_IdString_Content;
  61.  ULONG ENDMARK;
  62. } DataTab =
  63. {
  64.  INITBYTE(OFFSET(Node,         ln_Type),      NT_LIBRARY),
  65.  0x80, (UBYTE) OFFSET(Node,    ln_Name),      (ULONG) &ExLibName[0],
  66.  INITBYTE(OFFSET(Library,      lib_Flags),    LIBF_SUMUSED|LIBF_CHANGED),
  67.  INITWORD(OFFSET(Library,      lib_Version),  VERSION),
  68.  INITWORD(OFFSET(Library,      lib_Revision), REVISION),
  69.  0x80, (UBYTE) OFFSET(Library, lib_IdString), (ULONG) &ExLibID[0],
  70.  (ULONG) 0
  71. };
  72.  
  73.  
  74. /*************************************************************
  75. *************************************************************/
  76.  
  77. ULONG __saveds __stdargs L_OpenLibs(struct MuiToolkitBase *MuiToolkitBase)
  78. {
  79.  SysBase = (*((struct ExecBase **) 4));
  80.  
  81.  if( ! ( IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 37) ) )
  82.     return(FALSE);
  83.  
  84.  if( ! ( UtilityBase = OpenLibrary("utility.library", 37) ) )
  85.     return(FALSE);
  86.  
  87.  if( ! ( DOSBase = (struct DosLibrary *) OpenLibrary( "dos.library", 37) ) )
  88.      return(FALSE);
  89.  
  90.  if( ! (GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 37) ) )
  91.         return( FALSE );
  92.  
  93.  if( ! (MUIMasterBase = OpenLibrary(MUIMASTER_NAME, MUIMASTER_VMIN) ) )
  94.         return( FALSE );
  95.  
  96.  
  97.  MuiToolkitBase->mt_IntuitionBase = IntuitionBase;
  98.  MuiToolkitBase->mt_DOSBase       = DOSBase;
  99.  MuiToolkitBase->mt_GfxBase       = GfxBase;
  100.  MuiToolkitBase->mt_SysBase       = SysBase;
  101.  MuiToolkitBase->mt_UtilityBase   = (struct UtilityBase *)UtilityBase;
  102.  MuiToolkitBase->mt_MUIMasterBase = MUIMasterBase;
  103.  
  104.  
  105.  return(TRUE);
  106. }
  107.  
  108. /*************************************************************
  109. *************************************************************/
  110.  
  111. void __saveds __stdargs L_CloseLibs(void)
  112. {
  113.  if(DOSBase)       CloseLibrary((struct Library *) DOSBase );
  114.  if(GfxBase)       CloseLibrary((struct Library *) GfxBase );
  115.  if(IntuitionBase) CloseLibrary((struct Library *) IntuitionBase );
  116.  if(UtilityBase)   CloseLibrary((struct Library *) UtilityBase );
  117.  
  118.  if(MUIMasterBase) CloseLibrary((struct Library *) MUIMasterBase );
  119. }
  120.